/*
package com.huey.utils.aop;

import com.alibaba.fastjson.JSON;
import com.deepexi.util.DateUtils;
import com.google.common.collect.Lists;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.joda.time.DateTime;
import org.joda.time.Interval;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
import java.util.Random;

*/
/**
 * @author qmmao
 *//*

@Component
@Aspect
public class LogAspect {
    */
/**
     * TRACE_ID key
     *//*

    public static final String TRACE_ID_KEY = "TRACE_ID";

    */
/**
     * Time format : yyyyMMddHHmmssSSS
     *//*

    public static final String DATE_TIME_FORMAT = "yyyyMMddHHmmssSSS";

    private final static String TENANT_KEY = "tenantId";

    private final static String APP_ID_KEY = "appId";

    private static final Logger logger = LoggerFactory.getLogger(LogAspect.class);

    @Pointcut("execution (* com.glxytech.cloud.cost.controller..*.*(..))")
    public void apiLogAop() {
    }

    @Pointcut("execution (* com.glxytech.cloud.cost.rpc.controller..*.*(..))")
    public void rpcApiLogAop() {
    }

    @Pointcut("execution (* com.glxytech.cloud.cost.remote.client..*.*(..))")
    public void remoteLogAop() {
    }

    @Pointcut("execution (* com.glxytech.cloud.cost.handler..*.*(..))")
    public void handlerLogAop() {
    }

    @Around("handlerLogAop()")
    public Object jobAroundApi(ProceedingJoinPoint point) throws Throwable {
        String traceId = DateUtils.toDateText(new Date(), DATE_TIME_FORMAT) + new Random().nextInt(9999);
        MDC.put(TRACE_ID_KEY, traceId);
        logger.info("日志统一打印 ↓ ↓ ↓ ↓ ↓ ↓ {}.{}() start ↓ ↓ ↓ ↓ ↓ ↓,参数:\n{}", point.getSignature().getDeclaringTypeName(), point.getSignature().getName(), argsToString(point.getArgs()));
        DateTime startTime = new DateTime();
        DateTime endTime;
        Interval interval;
        Object response;
        try {
            //执行该方法
            response = point.proceed();
        } catch (Exception e) {
            logger.error("", e);
            endTime = new DateTime();
            interval = new Interval(startTime, endTime);
            logger.info("日志统一打印 ↑ ↑ ↑ ↑ ↑ ↑ {}.{}() end ↑ ↑ ↑ ↑ ↑ ↑,响应时间:{}毫秒", point.getSignature().getDeclaringTypeName(), point.getSignature().getName(), interval.toDurationMillis());
            throw e;
        }
        endTime = new DateTime();
        interval = new Interval(startTime, endTime);
        logger.info("日志统一打印 ↑ ↑ ↑ ↑ ↑ ↑ {}.{}() end ↑ ↑ ↑ ↑ ↑ ↑,响应时间:{}毫秒,响应内容:\n{}", point.getSignature().getDeclaringTypeName(), point.getSignature().getName(), interval.toDurationMillis(), argsToString(response));
        return response;
    }

    */
/**
     * 日志打印切面
     *
     * @param point
     * @param point
     * @return
     * @throws Throwable <p>
     *                   登陆验证切面
     * @throws Throwable
     *//*


    @Around("apiLogAop() || rpcApiLogAop() || remoteLogAop()")
    public Object aroundApi(ProceedingJoinPoint point) throws Throwable {
        logger.info("日志统一打印 ↓ ↓ ↓ ↓ ↓ ↓ {}.{}() start ↓ ↓ ↓ ↓ ↓ ↓,参数:\n{}", point.getSignature().getDeclaringTypeName(),
                point.getSignature().getName(), argsToString(initArgs(point.getArgs())));
        DateTime startTime = new DateTime();
        DateTime endTime;
        Interval interval;
        Object response;
*/
/*        if (RequestContextHolder.getRequestAttributes() != null) {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            //AppRuntimeEnv.setTenantId(request.getParameter(TENANT_KEY));
            //AppRuntimeEnv.setAppId(request.getParameter(APP_ID_KEY));
        }*//*

        try {
            //执行该方法
            response = point.proceed();
        } catch (Exception e) {
            logger.error("请求异常", e);
            throw e;
        }
        endTime = new DateTime();
        interval = new Interval(startTime, endTime);
        logger.info("日志统一打印 ↑ ↑ ↑ ↑ ↑ ↑ {}.{}() end ↑ ↑ ↑ ↑ ↑ ↑,响应时间:{}毫秒,响应内容:\n{}", point.getSignature().getDeclaringTypeName(), point.getSignature().getName(), interval.toDurationMillis(), argsToString(response));
        return response;
    }

    private Object[] initArgs(Object[] args) {
        if (args == null || args.length < 1) {
            return new Object[]{};
        }
        List<Object> result = Lists.newArrayListWithExpectedSize(args.length);

        for (Object object : args) {
            if (object instanceof HttpServletResponse) {
                continue;
            }
            result.add(object);
        }
        return result.toArray();
    }

    private String argsToString(Object object) {
        if (object instanceof HttpServletRequest) {
            return "httpServletRequest";
        }
        try {
            return JSON.toJSONString(object);
        } catch (Exception e) {
            logger.error("", e);
        }
        return String.valueOf(object);
    }
}
*/
